package com.ruoyi.project.experimentresult.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.page.TableSupport;
import com.ruoyi.project.experimentcheck.domain.ExperimentCheck;
import com.ruoyi.project.experimentcheck.service.ExperimentCheckService;
import com.ruoyi.project.experimentresult.domian.TbExperimentResult;
import com.ruoyi.project.experimentresult.mapper.TbExperimentResultMapper;
import com.ruoyi.project.myexperiment.domain.MyExment;
import com.ruoyi.project.property.domain.LabProperty;
import com.ruoyi.project.property.service.ILabPropertyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

@Controller
@RequestMapping("/website/experimentresult")
public class TbExperimentResultController extends BaseController {
    private String prefix = "system/experimentresult";
    @Autowired
    private ILabPropertyService labPropertyService;

    @Autowired
    private TbExperimentResultMapper tbExperimentResultMapper;


    @Autowired
    private ExperimentCheckService experimentCheckService;

    @RequiresPermissions("website:experimentresult:view")
    @GetMapping()
    public String teach()
    {
        return prefix + "/result";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:experimentresult:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbExperimentResult tbExperimentResult)
    {
        /*TableDataInfo rspData = new TableDataInfo();
        List<TbExperimentResult> userList = new ArrayList<TbExperimentResult>(Arrays.asList(new TbExperimentResult[results.size()]));
        //Collections.copy(userList, results);
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
        {
            rspData.setRows(userList);
            rspData.setTotal(userList.size());
            return rspData;
        }
        Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
        Integer pageSize = pageDomain.getPageNum() * 10;
        if (pageSize > userList.size())
        {
            pageSize = userList.size();
        }
        rspData.setRows(userList.subList(pageNum, pageSize));
        rspData.setTotal(userList.size());
        return rspData;*/
        startPage();
        tbExperimentResult.setCreateId(getUserId());
        List<TbExperimentResult> list = tbExperimentResultMapper.getAllExperiment(tbExperimentResult);
        /*for (MyExment lists:list){
            if (lists.getClassAddress()!=null && lists.getOrderTime()!=null && lists.getSection()!=null){
                lists.setExperimentMessage(lists.getClassAddress().toString()+"-"+lists.getOrderTime().toString()+""+lists.getSection().toString());
            }
        }*/
        return getDataTable(list);

    }

    @GetMapping("/look")
    public String get(int id, ModelMap map){
        System.err.println(id);
        map.put("id",id);
        return "experimentcheck/experimentcheck";
    }
    /*private final static List<TbExperimentResult> results= new ArrayList<TbExperimentResult>();
    {
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
        results.add(new TbExperimentResult(1L,"生物质发电虚拟仿真实验","生物质发电虚拟仿真实验","2019-09-10","2019-09-10","已提交"));
    }*/
}
